"""

"""
#########################################################################

#########################################################################
from osv import osv, fields

class SaleOrder(osv.osv):
    '''
    Sale Order
    '''
    _inherit = 'account.invoice'
    
    _columns = {
        'coupon_code':fields.char('Discount Code', size=20),
    }
    
    def apply_promotions(self, cursor, user, ids, context=None):
        """
        Applies the promotions to the given records
        @param cursor: Database Cursor
        @param user: ID of User
        @param ids: ID of current record.
        @param context: Context(no direct use).
        """
        promotions_obj = self.pool.get('promos.rules1')
        for invoice_id in ids:
            promotions_obj.apply_promotions(cursor, user, 
                                            invoice_id, context=None)
            
        return True
            
SaleOrder()


class SaleOrderLine(osv.osv):
    '''
    Sale Order Line
    '''
    _inherit = "account.invoice.line"
    
    _columns = {
        'promotion_line':fields.boolean(
                "Promotion Line",
                help="Indicates if the line was created by promotions"
                                        )
    }
SaleOrderLine()
